import { http } from "@/utils/http";
import type {
  AdClearApplyFormItemProps,
  AdClearApplyTableItemProps,
  AdClearApplyHandleFormItemProps,
  SelectOption
} from "./types";

export type AdClearApplyResult = {
  success: boolean;
  data: {
    /** 列表数据 */
    list: Array<AdClearApplyTableItemProps>;
    /** 总数 */
    total: number;
    /** 页码 */
    page: number;
    /** 每页数量 */
    pageSize: number;
    /** 账号选项 */
    account_options: Array<SelectOption>;
    /** 状态选项 */
    state_options: Array<SelectOption>;
    /** 申请人选项 */
    creator_options: Array<SelectOption>;
  };
};

export type AdClearApplyCreateResult = {
  success: boolean;
  data: any;
  message: string;
};

export type AdClearApplyHandleResult = {
  success: boolean;
  data: any;
  message: string;
};

/** 获取清零申请列表 */
export const getAdClearApplyList = (data?: object) => {
  return http.request<AdClearApplyResult>("get", "/ad-clear-apply", { params: data });
};

/** 创建清零申请 */
export const createAdClearApply = (data: AdClearApplyFormItemProps) => {
  return http.request<AdClearApplyCreateResult>("post", "/ad-clear-apply", { data });
};

/** 处理清零申请 */
export const handleAdClearApply = (id: number, data: AdClearApplyHandleFormItemProps) => {
  return http.request<AdClearApplyHandleResult>("put", `/ad-clear-apply/${id}`, { data });
};

/** 删除清零申请 */
export const deleteAdClearApply = (id: number) => {
  return http.request<any>("delete", `/ad-clear-apply/${id}`);
}; 